home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / test / fraction.c < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  50 lines

  1. /* Test class Fraction
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2033
  13.     Computer Systems Laboratory
  14.     Division of Computer Research and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-1111
  18.     uucp: uunet!nih-csl!kgorlen
  19.     Internet:kgorlen@alw.nih.gov
  20.  
  21. Function:
  22.     
  23. Modification History:
  24.     
  25. $Log:    fraction.c,v $
  26.  * Revision 3.0  90/05/20  00:29:11  kgorlen
  27.  * Release for 1st edition.
  28.  * 
  29. */
  30. static char rcsid[] = "$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/test/RCS/fraction.c,v 3.0 90/05/20 00:29:11 kgorlen Rel $";
  31.  
  32. #include "Fraction.h"
  33.  
  34. main()
  35. {
  36.     Fraction a(40902,24140), b(7,66), c(17,12);
  37.     cout << "a = " << a << endl;
  38.     cout << "b = " << b << endl;
  39.     cout << "c = " << c << endl;
  40.     cout << "7/66 + 17/12 = " << (b+c) << endl;
  41.     cout << "7/66 - 17/12 = " << (b-c) << endl;
  42.     cout << "7/66 * 17/12 = " << (b*c) << endl;
  43.     cout << "7/66 / 17/12 = " << (b/c) << endl;
  44.     cout << "7/66 < 11/100 = " << (b<Fraction(11,100)) << endl;
  45.     cout << "Fraction(0.5) = " << Fraction(0.5) << endl;
  46.     cout << "Fraction(0.333333e6) = " << Fraction(0.333333e6) << endl;
  47.     cout << "Fraction(0.333333e-6) = " << Fraction(0.333333e-6) << endl;
  48.     cout << "(double)Fraction(1,2) = " << (double)Fraction(1,2) << endl;
  49. }
  50.